home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 June / EnigmA AMIGA RUN 19 (1997)(G.R. Edizioni)(IT)[!][issue 1997-06][EAR-CD III].iso / games / interactivefiction / agt / source / agtread.h next >
C/C++ Source or Header  |  1996-10-25  |  23KB  |  673 lines

  1. /*  agtread.h-- Header for all AGiliTy files. */
  2. /* Copyright 1996  Robert Masenten                        */
  3. /*                                                        */
  4. /* This is part of the source for AGiliTy: the (Mostly) Universal  */
  5. /*       AGT Interpreter                                           */
  6.  
  7. /*
  8.     This is the master header file for all of the AGT stuff.
  9.       It includes the global variables, the data types, etc.
  10.       (everything that is read in from the game file).
  11.     Variables not read in from the game file but used internally
  12.       by the interpreter are declared in uagt.h.
  13.     This file also contains most of the configuration information
  14.       including the platform-dependent #define statements 
  15. */
  16.  
  17. #include <stdlib.h>
  18. #include <stdio.h>
  19. #include <string.h>
  20.  
  21. #ifndef global    /* Don't touch this */
  22. #define global extern
  23. #define global_defined_agtread
  24. #endif
  25.  
  26. #ifdef __MSDOS__  /* This works under Borland C, at least */
  27. #define MSDOS
  28. #endif
  29.  
  30.  
  31. /* ------------------------------------------------------------------- */
  32. /* PLATFORM SPECIFIC DEFINITIONS, ETC. */
  33. /* Things you can currently define: */
  34. /*    fix_ascii: 1=translate IBM character set, 0=don't */
  35. /*    NEED_STR_CMP: define if strcasecmp() not defined on your system */
  36. /*    NEED_STRN_CMP: define if strncasecmp() not defined on your system */
  37. /*    HAVE_STRDUP: define if strdup() exists on your system */
  38. /*    REPLACE_GETFILE: define if you replace the default get_user_file(). */
  39. /*    REPLACE_MENU if you replace agt_menu().                 */
  40. /*    REPLACE_MAIN: define if you replace the default main(). */
  41. /*  (replacements should be defined in the relevant os_<platform>.c file) */
  42. /*    DA1,DA2,...DA6,DSS,pTTL: file name extensions for the various AGT 
  43.             files */
  44. /*   HAVE_SLEEP if your platform has the sleep() function */
  45. /*   BUFF_SIZE is the maximum size of the buffer to use when reading
  46.        in files. Regardless, it will be made no bigger than the file 
  47.        being read in and no smaller than the record size; thus setting
  48.        it to 0 will cause the smallest buffer to always be used and
  49.        setting this to 1MB will in practice always use a buffer the
  50.        sizs of the file. It defaults to 32K */
  51. /*   CBUF_SIZE is the maximum size of the buffer used for reading in 
  52.        the Master's Edition DA6 files; the size of the buffer in bytes
  53.        is twice this value (since an individual token is two bytes long). */
  54. /*   DOHASH to use a hash table for dictionary searches; the only 
  55.        reason not to have this would be memory */
  56. /*   HASHBITS determines the size of the hash table: (2^HASHBITS)*sizeof(word);
  57.        the hash table must be at least as large as the dictionary.
  58.        In practice this means HASHBITS must be at least 11;
  59.        it defaults to 12. */
  60. /*   MAXSTRUC The maximum size (in chars) which a single data structure can
  61.        be on this platform. This defaults to 1MB (i.e. no limit for 
  62.        practical purposes). In practice I know of no game files that
  63.        require any structures bigger than about 30K.  */
  64. /*   LOWMEM Define this if you are low on memory. At the moment this
  65.        only saves a few K.*/
  66. /*   PORTSTR Is the string describing this particular port.
  67.         e.g. #define PORTSTR "OrfDOS Port by R.J. Wright" */ 
  68. /*   UNIX_IO  if you have Unix-like low level file I/O functions.
  69.        (MS-DOS, for example, does). This speeds up the reading
  70.        of the large game data files on some platforms */
  71.  
  72.  
  73. /* force16 is used purely for debugging purposes, to make sure that
  74.    everything works okay even with 16-bit ints */
  75. /* #define force16 */
  76.  
  77. #define DOHASH
  78.  
  79. /* This works with Borland C; don't know about other DOS C compilers  */
  80. #ifdef MSDOS
  81. #define FAR far
  82. #define strcasecmp(s1,s2) stricmp(s1,s2)
  83. #define NEED_STRN_CMP
  84. #define fix_ascii 0  /* DON'T translate IBM character set */
  85. #define HAVE_SLEEP
  86. #define BUFF_SIZE (16*1024L)
  87. #define CBUF_SIZE (20000L)
  88. #define UNIX_IO
  89. #define MAXSTRUC (64L*1024L)  /* DOS 64K Limit */
  90. #define FAST_FIXSIGN
  91. #define PORTSTR "DOS Version"
  92. #endif
  93.  
  94. #ifdef LINUX
  95. #define LINUX_COLOR
  96. #define fix_ascii 1  /* Don't translate IBM character set */
  97. #define HAVE_TPARAM
  98. #define UNIX
  99. #define HAVE_STRDUP
  100. #define BUFF_SIZE (1024L*1024L) 
  101. #define MAXSTRUC (1024L*1024L) /* If we're asking for more than 1 MB, something
  102.                 is wrong. */
  103. #define CBUF_SIZE (20000L)  
  104. #define FAST_FIXSIGN
  105. /* #define SORT_META*/    /* This doesn't work yet */ 
  106. #define PORTSTR "Linux Version"
  107. #endif
  108.  
  109. #ifdef SUN
  110. #define NO_TERMCAP_H
  111. #define UNIX
  112. #define BUFF_SIZE (1024L*1024L)
  113. #define MAXSTRUC (1024L*1024L) 
  114. #define CBUF_SIZE (20000L)  
  115. #define PORTSTR "UNIX Version"
  116. #endif
  117.  
  118. #ifdef AMIGA
  119. #define NEED_STR_CMP
  120. #define NEED_STRN_CMP
  121. #undef HAVE_STRDUP
  122. #define REPLACE_GETFILE
  123. #define FAST_FIXSIGN
  124. #define BUFF_SIZE (256L*1024L)
  125. #define CBUF_SIZE (20000L)
  126. #define UNIX_IO
  127. #define PORTSTR "Amiga Version by David Kinder"
  128. #define READFLAG O_RDONLY
  129. #endif
  130.  
  131. #ifdef PLAIN
  132. #define NEED_STR_CMP
  133. #define NEED_STRN_CMP
  134. #define BUFF_SIZE 0    
  135. #define CBUF_SIZE (5000L)
  136. #define MAXSTRUC (32L*1024L) /* As I recall, 32K is the minimum required by
  137.                 the ANSI standard */
  138. #define PORTSTR "Pure ANSI C version"
  139. #endif
  140.  
  141.  
  142. /* __GNUC__ */
  143.  
  144.  
  145.  
  146.  
  147. /* ------------------------------------------------------------------- */
  148. /* DEFAULTS FOR "PLATFORM SPECIFIC" DEFINES */
  149.  
  150. #ifdef __POSIX__
  151. #ifndef UNIX
  152. #define UNIX
  153. #endif
  154. #endif
  155.  
  156. #ifdef UNIX
  157. #define HAVE_SLEEP
  158. #define UNIX_IO
  159. #endif
  160.  
  161. #ifdef __STRICT_ANSI__
  162. #define NEED_STR_CMP
  163. #define NEED_STRN_CMP
  164. #ifdef HAVE_STRDUP
  165. #undef HAVE_STRDUP
  166. #endif
  167. #endif
  168.  
  169. #ifndef fix_ascii
  170. #define fix_ascii 1  /* Translate IBM character set by default */
  171. #endif
  172.  
  173. #ifndef BUFF_SIZE
  174. #ifdef LOWMEM
  175. #define BUFF_SIZE 0   /* i.e. unbuffered */
  176. #else
  177. #define BUFF_SIZE (32L*1024L)  /* 32K */
  178. #endif
  179. #endif /* BUFF_SIZE */
  180.  
  181. #ifndef MAXSTRUC
  182. #define MAXSTRUC (1024L*1024L)
  183. #endif
  184.  
  185. #ifndef HASHBITS
  186. #ifdef LOWMEM
  187. #define HASHBITS 11   /* 2K entries */
  188. #else
  189. #define HASHBITS 12   /* 4K entries in hash table */
  190. #endif
  191. #endif /* HASHBITS */
  192.  
  193. #ifndef FAR
  194. #define FAR   /* Define FAR to be blank */
  195. #endif 
  196.  
  197. /* ------------------------------------------------------------------- */
  198. /* FILENAME EXTENSIONS */
  199. /* These are the various filename extensions for the different data files.*/
  200.  
  201. #ifndef DA1
  202. #define DA1 ".da1"   /* General info (text file) */
  203. #define DA2 ".da2"   /* Rooms */
  204. #define DA3 ".da3"   /* Items */
  205. #define DA4 ".da4"   /* Creatures */
  206. #define DA5 ".da5"   /* Commands, headers */
  207. #define DA6 ".da6"   /* Commands, code (Master's Ed only) */
  208. #define DSS ".d$$"   /* Description strings */
  209. #define pTTL ".ttl"  /* Title file */
  210. #define pINS ".ins"  /* Instruction file */
  211. #define pVOC ".voc"  /* Menu vocabulary file */
  212. #define pCFG ".cfg"  /* Game configuration file */
  213. #define pOPT ".opt"  /* Interface specification file */
  214. #define pHNT ".hnt"  /* Popup hint file; not used yet. */
  215. #endif
  216.  
  217. /* ------------------------------------------------------------------- */
  218. /* GLOBAL FLAGS */
  219. /* Many of the following should be made into command line options */
  220.  
  221. /* #define AGT_16BIT */ /* Force interpreter to use 16-bit qunatities */
  222. /* #define DUMP_VLIST  */ /* Dump out the verb list info */
  223. /* #define USE_CMD_INDEX */  /* Read in metacommand index data for objects */
  224. /* #define DEBUG_ENCRYPT */ /* Turn on debugging of encryption routine */
  225. #define def_DIAG 1   /* Print out diagnostic data? */
  226. #define def_interp_arg 1  /* Decipher arguments to opcodes? */
  227. #define def_debug_da1 0 
  228.          /* used to analyse .DA1 files of new gamefile versions */
  229. #define def_RAW_CMD_OUT 0  /*Print CMDs out raw, undecoded; sometimes useful
  230.             when trying to understand new gamefile version */ 
  231. #define def_ERR_LEVEL 2    /* Level of error reporting. */
  232.                    /* 0== almost none */
  233.                    /* 1== Report possibly serious conditions */
  234.            /* 2== Report any fall from perfection */
  235.  
  236.  
  237. #define SS_GRAIN 1024  /* Granularity of size request for static string
  238.               array (to avoid calling rrealloc too often) */
  239. #define SYN_GRAIN 32 /* Granularity of requests for synonym array; this
  240.                is in units of sizeof(word) */
  241. #define MAX_BADTOK 10  /* How many bad tokens to report before giving
  242.               up */
  243.  
  244. /* ------------------------------------------------------------------- */
  245. /* DEFINES OF GLOBAL PARAMETERS */
  246.  
  247. /* 
  248. None of these are used any more, but I leave them here for reference
  249. #define MAX_ROOM 300
  250. #define MAX_NOUN 300
  251. #define MAX_CREAT 200
  252. #define MAX_CMD 1500
  253. #define MAX_QUEST 100
  254. #define MAX_MSG 1000
  255. #define MAX_PICT 250
  256. #define ABS_MAX_REC_CMD 34
  257. #define MAX_OBJ (MAX_ROOM+MAX_NOUN+MAX_CREAT)
  258. #define SYNCNT 15    
  259. */
  260.  
  261. #define FORMAT_CODE 0xFF  /* Character used for special formatting codes:
  262.                  --in 1.8x games, it designates bold
  263.                  --in AGX+ games, it will prefix format codes
  264.                  --otherwise it designates black (replacing
  265.                  0, which has obvious problems) */
  266. #define LAST_TEXTCODE 8  /* Last ascii code to be used for text attributes */
  267. #define NUM_ERR 185  /* Number of standard error messages */
  268. #define MAX_SUB 15    /* Maximum number of subroutines */
  269. #define MAX_USTR 25   /* Maximum number of user strings */
  270. #define MAX_PIX 30
  271. #define MAX_FLAG_NOUN 33
  272.  
  273. #define BASE_VERB 58    /* Number of built in verbs-- this number 
  274.              includes ANY, which is verb 0. */
  275. #define DVERB 50       /* Number of real dummy_verbs */
  276. #define DUMB_VERB (DVERB+MAX_SUB)  /* Number of dummy verbs and subroutines */
  277. #define AUX_VERB 14    /* Additional verbs supported by the interpreter */
  278. #define MAX_VERBS (BASE_VERB+DUMB_VERB)
  279. #define TOTAL_VERB (BASE_VERB+DUMB_VERB+AUX_VERB)
  280.  
  281. /* The following numbers refer to the ideal code we are translating into,
  282.    not the paramaters for the actual data file we're reading. */
  283. #define MAX_TOKEN_ID 250   /* Upper limit on legal (raw) token values.
  284.                Doesn't need to be exact. */
  285. #define MAX_COND 118
  286. #define START_ACT 1000  /* First action code */
  287. #define PREWIN_ACT 1113  /* Last action code before WinGame */
  288. #define WIN_ACT 2000    /* Value of win opcode: this and later opcodes
  289.              will be moved up to make room for more action
  290.              tokens. */
  291. #define END_ACT (WIN_ACT+2)  /* Lowest command-terminating action code */
  292. #define MAX_ACT (WIN_ACT+4)  /* Highest action code */
  293.  
  294. /* ------------------------------------------------------------------- */
  295. /* DEFINITIONS OF SPECIAL DATA TYPES */
  296. /* These should by platform-independent. */
  297.  
  298. #ifdef force16  /* This is for debugging purposes */   
  299. #define int short int
  300. #endif
  301.  
  302. typedef unsigned char uchar;
  303. typedef signed char schar;
  304. typedef short integer;  /* Should be a 16+-bit signed numeric type */
  305. typedef unsigned long int32;  /* Should be a 32+-bit unsigned numeric type */
  306. typedef char tline[81]; /* Both of these must include terminating null */
  307. typedef char words[25]; /* ...23 in classic, 16 in master's */
  308. typedef short word;     /* Pointer into dictionary */
  309. typedef short slist; /* Index into synlist marking beginning of this 
  310.             synonym list.  [SYNCNT] 
  311.             list of word pointers -- eg synonyms */
  312. typedef uchar bool;
  313. typedef char filename[10];  /* Datatype used for picture, sound, etc. names*/
  314.  
  315. /* ------------------------------------------------------------------- */
  316. /* DATA STRUCTURE DEFINITIONS */
  317. /* All of the internal data structures used to store the contents of the */
  318. /*   game file... */
  319.  
  320. typedef struct {
  321.   long start,len;
  322. } descr_ptr;
  323.  
  324. typedef struct {
  325.   char *opcode;
  326.   integer argnum;
  327.   integer arg1,arg2;
  328. } opdef;  /* Opcode table entry */
  329.  
  330. /* This is the data type for opcode correction entries */
  331.  
  332. typedef struct {
  333.   integer old,new;  /* Old and new values. */
  334. } cmd_fix_rec;
  335.  
  336.  
  337. typedef cmd_fix_rec *fix_array;
  338.  
  339. typedef struct {
  340.   char *name;  /* [31] */
  341.   int32 flag_noun_bits,PIX_bits;  /* Master's Ed. only */
  342.   slist replacing_word;  /* List of words to be replaced */
  343.   word replace_word;   /* Word that does replacing */
  344.   word autoverb;     /* Verb automatically executed on entry to room */
  345.   integer path[13];
  346.   integer key;
  347.   integer nouns_inside;  /* # nouns inside */
  348.   integer contents;   /* Used internally by the interpreter; not read in
  349.              from the game file */
  350.   integer points;
  351.   integer light;  /* Object that lights room; 0=none needed, 1=any */
  352.   integer pict,initdesc;
  353.   bool seen, locked_door;
  354.   bool end, win, killplayer;
  355. } room_rec;
  356.  
  357. typedef struct {
  358.   char *shortdesc; /* tline */
  359.   char *position; /* 23 characters in position for classic ed, 31 for ME */
  360.   slist syns;   /* List of synonyms */
  361.   word name, adj;
  362.   word pos_prep, pos_name;   /* Used internally by the interpreter */
  363.                        /* pos_prep==-1 means use noun.position */
  364.   integer nearby_noun; /* Noun this noun is behind */
  365.   integer num_shots;
  366.   integer points;
  367.   integer weight, size;
  368.   integer key;
  369.   integer initdesc,pict;
  370.   integer nouns_inside;  /* Number of nouns inside */
  371.   integer location;    /* 1=carried, 1000=worn */
  372.   integer contents, next;   /* Used internally by the interpreter; not read in
  373.              from the game file */
  374.  
  375.   uchar sing_plur;
  376.   bool something_pos_near_noun;  /* Anybody behind us? */
  377.   bool has_syns;
  378.   bool pushable, pullable, turnable, playable, readable;
  379.   bool on, closable, open, lockable, locked, edible, wearable;
  380.   bool drinkable, poisonous, movable, light;
  381.   bool shootable;
  382.   bool win;
  383. /*  words related; related_name */
  384. } noun_rec;
  385.  
  386.  
  387. typedef struct {
  388.   char *shortdesc; /* tline */
  389.   slist syns;
  390.   word name;
  391.   word adj;
  392.   integer location;
  393.   integer contents, next;   /* Used internally by the interpreter; not read in
  394.              from the game file */
  395.   integer weapon;  /* Killed by this */
  396.   integer points;
  397.   integer nouns_inside;  /* Number of nouns it's carrying */
  398.   integer counter;  /* How many times has player been nasty to it? */
  399.   integer threshold, timethresh, timecounter;
  400.   integer pict,initdesc;
  401.   bool has_syns;
  402.   bool groupmemb;
  403.   bool hostile;
  404.   uchar gender;
  405. } creat_rec;
  406.  
  407. typedef struct {
  408.   integer verbnum;  /* Contains either actor or verb information. */
  409.   word verbcmd, nouncmd, objcmd, prep;  /* prep only in ME games */
  410.   integer *data; /* MaxSizeCommand */
  411.   integer cmdsize; /* Number of commands */
  412. /*  integer ptr; */ /* In ME games-- see below for replacement */
  413. } cmd_rec;
  414.  
  415. /* FRS=file record size; these are the sizes to be allocated to the buffer
  416.    used to read in the various records from the files; they should be at
  417.    least as big as the worst case scenario. */
  418. #define FRS_ROOM 220
  419. #define FRS_NOUN 310
  420. #define FRS_CREAT 240
  421. #define FRS_CMD 150
  422.  
  423.  
  424. /* ------------------------------------------------------------------- */
  425. /* GLOBAL VARIABLES */
  426.  
  427. global uchar DIAG, interp_arg, debug_da1, RAW_CMD_OUT;
  428. global int ERR_LEVEL;
  429. global bool mars_fix;
  430.  
  431. global long game_sig; /* 2-byte quantity used to identify game files */
  432.                    /* (It's declared long to avoid overflow problems when
  433.               computing it) */
  434. global long MAX_CMD_SIZE;
  435. global long start_room, treas_room, ressurect_room, max_lives, max_score;
  436. global long start_time, delta_time;
  437. global uchar score_mode, statusmode;
  438. global bool debug_mode, freeze_mode, milltime_mode, bold_mode;
  439. global long maxroom, maxnoun, maxcreat, last_cmd;
  440. global long MaxQuestion, first_room, last_room, first_noun, last_noun,
  441.     first_creat, last_creat;
  442. global long first_message, last_message, num_verbs;
  443. global long numglobal; /* Number of global nouns */
  444. global long maxpict, maxpix, maxfont, maxsong;
  445.  
  446. global word FAR flag_noun[MAX_FLAG_NOUN],*globalnoun;
  447. global word FAR pix_name[MAX_PIX];
  448.  
  449. global filename *pictlist,*pixlist,*fontlist,*songlist;
  450.  
  451. global tline *userstr; /*[MAX_USTR];*/
  452.  
  453.  
  454. global descr_ptr intro_ptr;
  455. global descr_ptr FAR err_ptr[NUM_ERR];
  456.  
  457.  
  458. global descr_ptr *msg_ptr; /* [MAX_MSG];*/
  459. global descr_ptr *help_ptr, *room_ptr, *special_ptr; /*[ROOM] */
  460. global descr_ptr *noun_ptr, *text_ptr, *turn_ptr, /* [NOUN] */
  461.             *push_ptr, *pull_ptr, *play_ptr;
  462. global descr_ptr *talk_ptr, *ask_ptr, *creat_ptr; /* [CREAT] */
  463.  
  464. global descr_ptr *quest_ptr, *ans_ptr; /* [MAX_QUEST] */
  465. global tline *question, *answer; /* [MAX_QUEST] */
  466.  
  467. global int ver,aver;  /* ver: 0=unknown, 1=small, 2=big, 4=masters1.5 */
  468.  
  469. global slist FAR synlist[MAX_VERBS+1];
  470. global bool anyspecialcmd;
  471.  
  472. /* All of the following are allocated dynamically */
  473. global room_rec *room; /* [MAX_ROOM]; */
  474. global creat_rec *creature; /* [MAX_CREAT]; */
  475. global noun_rec *noun; /* [MAX_NOUN]; */
  476. global cmd_rec *command;
  477.  
  478.  
  479. global word FAR sub_name[MAX_SUB];  /* Dictionary id's of all subroutines */
  480. global words *dict;
  481. global int dp;  /* Dictionary pointer: number of words in dict */
  482.  
  483. global char *static_str; /*Static string space */
  484. global long strptr; /* Pointer to end of used space in above */
  485. global long ss_size; /* Current size of static string space */
  486.  
  487. global word *syntbl;  /* Synonym list space */
  488. global slist synptr; /* Points to end of used space */
  489. global slist syntbl_size;
  490.  
  491. global short verbptr[TOTAL_VERB],verbend[TOTAL_VERB];
  492.  
  493.  
  494. /*The following are all set to NULL after agtread finishes. */
  495. global long *cmd_ptr; /* ME only;Points to cmd start locs in gamefile.*/
  496. global long *room_name,*noun_sdesc,*noun_pos,*creat_sdesc;
  497.  
  498. /* ------------------------------------------------------------------- */
  499. /* SYMBOLIC CONSTANTS   */
  500.  
  501. /* A-Version Codes */
  502. #define AGT10 1     /* SPA-- token encoding isn't supported */
  503. #define AGT118 2    /* TAMORET, PORK II  */
  504. #define AGT12  3   /* SOS,... */ 
  505. #define AGTCOS 4   /* COSMOS and SOGGY: enhanced versions of 1.3x */
  506. #define AGT135 5   /* By far the most common version; includes practically
  507.               every version of Classic AGT from 1.19 to 1.7 */
  508. #define AGT182 6  /* 1.8x support hasn't been tested */
  509. #define AGT183A 7
  510. #define AGT183 8
  511. #define AGT15 9 /* HOTEL -- token encoding not known */
  512. #define AGT15F 10  /* MDTHIEF-- "     "      "   " */
  513. #define AGTME10 11  /* CLIFF2, ELF20  */
  514. #define AGTME15 12    /* WOK */
  515. #define AGTME155 13 /* TJA */
  516. #define AGTME16 14  /* also includes v1.56 */
  517.  
  518. #define AGTMAST AGTME16
  519. #define AGTCLASS AGT15F  /* Dividing line between master's ed and classic */
  520. #define AGT18 AGT182  /* Defines lowest 1.8x version */
  521. #define AGT18MAX AGT183 /* Defines the highest 1.8x version */
  522.  
  523.  
  524. /* Argument Data Types (for the opcode table) */
  525. #define AGT_UNK 0     /* Unknown argument type */
  526.  
  527. /* The following can all mix and match in various ways and so are
  528.    put together as powers of two. */
  529. #define AGT_NONE 1  /* 0 is allowed */
  530. #define AGT_SELF 2  /* 1 is allowed */
  531. #define AGT_WORN 4  /* 1000 is allowed */
  532. #define AGT_ROOM 8  /* A room # is allowed */
  533. #define AGT_ITEM 16 /* An item # is allowed */
  534. #define AGT_CREAT 32  /* A creature # is allowed */
  535.  
  536. /* The rest of the values are always distinct; they never mix and so
  537.    they can be given simple consecutive indices */
  538. #define AGT_NUM 128
  539. #define AGT_FLAG 129
  540. #define AGT_VAR 130
  541. #define AGT_QUEST 131   /* Question */
  542. #define AGT_MSG 132     /* Message */
  543. #define AGT_STR 133    /* String */
  544. #define AGT_CNT 134  /* Counter */
  545. #define AGT_DIR 135   /* Direction */
  546. #define AGT_SUB 136   /* Subroutine */
  547. #define AGT_PIC 137    /* Picture */
  548. #define AGT_PIX 138   /* Room picture */
  549. #define AGT_FONT 139
  550. #define AGT_SONG 140
  551. #define AGT_ROOMFLAG 141
  552.  
  553. /* Verb flags for verbflag[]; these should be powers of 2 */
  554. #define VERB_TAKEOBJ 1
  555. #define VERB_META 2
  556.  
  557.  
  558.  
  559. /* ------------------------------------------------------------------- */
  560. /* FUNCTION PROTOTYPES AND INITIALIZED TABLES  */
  561.  
  562.  
  563. /* In AGTDATA.C */
  564. void init_dict(bool); /* 1=set of verblist, 0=don't */
  565. void reinit_dict(void);
  566. void free_dict(void);
  567. word search_dict(const char*);
  568. word add_dict(const char*);
  569. int verb_code(word);
  570. void addsyn(word);
  571. char *objname(int i);
  572. void agtwarn(const char*,int elev);
  573. void agtnwarn(const char*,int,int elev);
  574. void fatal(const char*);
  575. void sort_cmd(void);
  576.  
  577. extern char trans_ibm[];
  578. extern opdef cond_def[], act_def[], end_def[];  /* Tables of opcodes */
  579. global words *verblist; /* List of prexisting words, intialized by init_dict */
  580. extern fix_array FIX_LIST[];
  581. extern char exitname[13][4];
  582. extern char verstr[][10],averstr[][10];
  583. extern char version_str[],portstr[];
  584. global slist FAR auxsyn[TOTAL_VERB]; /* Built in synonym list */
  585. global slist FAR preplist[TOTAL_VERB];
  586. global uchar FAR verbflag[TOTAL_VERB]; /* Verb flags; see above */
  587.  
  588.  
  589.  
  590. /* In AGTREAD.C */
  591. void open_descr(char*);
  592. void close_descr(void);
  593. tline *read_descr(long start,long len);
  594. void free_descr(tline *p);
  595. void readagt(char *gamename,bool diag);
  596. void free_all_agtread(void); /* Cleans up everything allocated in agtread
  597.                   should only be called at the very end of
  598.                   the program */
  599.  
  600. /* In or used by AGTDBG.C */
  601. global bool *dbgflagptr;
  602. global long *dbgvarptr;
  603. global short  *dbgcntptr;
  604.  
  605. void debugout(const char *s);
  606. void argout(int dtype, int dval);
  607.  
  608. /* AGTTEST.C or INTERFACE.C */
  609. void writeln(const char *s);
  610.  
  611. /* In RMEM.C */
  612.  
  613. /* File routines */
  614. long file_size(FILE *f); /* Size of an open binary file */
  615. FILE *openfile(char *fname,char *ext,char *err,bool ferr);
  616. void readln(FILE *f, char *buff, int n); /* Read a line from a 'text' file */
  617.  
  618. /* (None of the following routines are at all reentrant) */
  619. long buffopen(char *fname,char *ext,int minbuffsize,char *rectype,int recnum);
  620.        /* Open file for our buffered routines and make it our current file;
  621.       returns the record size. Prints out error message on failure 
  622.       rectype="noun","room",etc.; recnum=expected # of objects in file */
  623. uchar *buffread(long index);
  624.     /* seek to index*recsize, read buff_rsize bytes, return pointer to a 
  625.        buffer with them. */
  626. void buffclose(void); /* Close the current file */
  627.  
  628.  
  629. /* Memory management variables and routines */
  630. global bool rm_trap; /* Trap memory allocation failures? */
  631. global bool rm_acct; /* Turn on rmem accounting, to locate memory leaks */
  632. global long rfree_cnt, ralloc_cnt; /* # of allocs/frees since acct turned on */
  633. global long rm_size, rm_freesize; /* These hold worst case values */
  634.  
  635. long get_rm_size(void);   /* These get the current values */
  636. long get_rm_freesize(void);
  637. void *rmalloc(long size);
  638. void r_free(void *p);
  639. #define rfree(p) (r_free(p),p=NULL) /* Traps errors & catch memory leaks */
  640. void *rrealloc(void *p,long size);
  641. char *rstrdup(const char *s);
  642.  
  643.  
  644. /* String utilities */
  645.  
  646. char *concdup(const char *s1,const char *s2); /* Concacate and duplicate */
  647.  
  648. #ifdef NEED_STR_CMP
  649. int strcasecmp(const char *s1,const char *s2);
  650. #endif
  651. #ifdef NEED_STRN_CMP
  652. int strncasecmp(const char *s1,const char *s2,size_t n);
  653. #endif
  654.  
  655.  
  656. /* The fixsign.. routines put together unsigned bytes to form signed ints */
  657.  
  658. #ifndef FAST_FIXSIGN
  659. short fixsign16(uchar n1,uchar n2);
  660. long fixsign32(uchar n1,uchar n2,uchar n3,uchar n4);
  661. #else 
  662. #define fixsign16(u1,u2) ( (u1) | ((u2)<<8) )
  663. #define fixsign32(u1,u2,u3,u4)  ( ((long)u1) | (((long)u2)<<8) | \
  664.                  (((long)u3)<<16) | (((long)u4)<<24) )
  665. #endif
  666.  
  667.  
  668. #ifdef global_defined_agtread
  669. #undef global
  670. #undef global_defined_agtread
  671. #endif
  672.  
  673.